
public class RiskContoler {

	/**
	 * The dice used to determine casualties.
	 */
	private Dice my_dice;
	
	
	public RiskContoler(){
		my_dice = new Dice();
	}
	
	public void playGame(){
	
	}
	
	/**
	 * @requires the countries be connected
	 * @requires attacking with more than 1 army
	 * @param the_attaker
	 * @param the_defender
	 */
	private void battle(final Territory the_attaker, final Territory the_defender){
		boolean engage = true;
		int attaking = the_attaker.getArmySize() - 1;
		int defending = the_defender.getArmySize();
		//assert the_attaker.isConected(the_defender.getName()) : "countries not connected";
		if(!the_attaker.isConected(the_defender.getName())){
			System.out.println("Contry not conected");
			return;
		} else if(attaking < 1){
			System.out.println("Army size is to small");
			return;
		}
		int[] attaker; 
		int[] defender;

		do{
			my_dice.roll();
			attaker = my_dice.getPips3();
			my_dice.roll();
			defender = my_dice.getPips2();
			if(attaker[3] > defender[2]){
				defending = defending -1;
			} else{
				attaking = attaking -1;
			}
			
			if(attaker[2] > defender[2]){
				defending = defending -1;
			} else{
				attaking = attaking -1;
			}
			if(attaking == 0 || defending == 0){
				engage = false;
			}
		}while(engage);
		if(defending > 0){
			the_defender.setArmySize(defending);
		} else {
			the_defender.setArmySize(attaking);
			the_defender.setOwner(the_attaker.getOwner());			
		}

	}
	
	
}
